﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Kanban.IDal
{
    public partial interface IBaseDAL<T> where T : class, new()
    {
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">entity</param>
        /// <returns></returns>
        Task<int> AddAsync(T entity);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        Task<bool> DeleteAsync(int id);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids">ids</param>
        /// <returns></returns>
        Task<bool> DeleteAsync(string ids);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="where">whereSql</param>
        /// <param name="param">param</param>
        /// <returns></returns>
        Task<bool> DeleteAsync(string where, object param = null);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">entity</param>
        /// <returns></returns>
        Task<int> UpdateAsync(T entity);

        /// <summary>
        /// 查询返回第一个
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        Task<T> GetModelAsync(int id);

        /// <summary>
        /// 查询返回第一个
        /// </summary>
        /// <param name="where">whereSql</param>
        /// <param name="param">param</param>
        /// <returns></returns>
        Task<T> GetModelAsync(string where, object param = null);

        /// <summary>
        /// 查询返回列表
        /// </summary>
        /// <param name="where">whereSql</param>
        /// <param name="param">param</param>
        /// <returns></returns>
        Task<IEnumerable<T>> GetListAsync(string where, object param = null);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="column">列</param>
        /// <param name="where">查询条件</param>
        /// <param name="orderby">排序</param>
        /// <param name="pageSize">页数</param>
        /// <param name="pageIndex">页码</param>
        /// <returns></returns>
        Task<Tuple<IList<object>, int>> GetModelsByPageAsync(string column, string where, string orderby, int pageSize, int pageIndex);

        Task<Tuple<IList<object>, int>> GetPageAsync(string table, string column, string where, string orderby, int pageSize, int pageIndex);
    }
}
